const userService =require('../services/userService')


exports.getUser = async (req,res) =>{
    try {
        const result = await userService.findUser(req.params.username);
        res.json(result);
    } catch (error) {
        res.status(404).json({error:error.message});
    }
}

exports.cerateUser = async (req,res) =>{
    try {
      const result = await userService.cerateUser(req.body);
      res.json(result);
    } catch (error) {
        res.status(400).json({error:error.message});
    }
}

exports.login = async (req,res) =>{
    console.log(req.body);
    try {
        const result = await userService.login(req.body);
        res.json(result);
    } catch (err) {
        console.error(err);
        res.status(500).json({ error: err.message });
    }
}